<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var hasAllCodes = function (s, k) {
      let left = 0;
      let right = k;
      let mySet = new Set();

      while (right <= s.length) {
        mySet.add(s.substring(left, right));
        left++;
        right++;
      }

      let myArr = [...mySet];
      return myArr.length == Math.pow(2, k);

    };
    console.log(hasAllCodes("00110110", 2));
  </script>
</body>

</html>